#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
void sig_chld(int sign)
{
    pid_t pid;
    int status;
    pid = wait(&status);
    printf("child terminated.\n");
    return;
}
int main(void)
{
    signal(SIGCHLD, sig_chld);
    char buffer[4096];
    pid_t pid = fork();
    if (pid == 0)
    {
        sleep(10);
        printf("child: %d finished.\n", getpid());
    }
    else
    {

        // pid_t childPid = wait(NULL);
        sleep(20);
        printf("father: %d\n", getpid());

    }

    return 0;
}